package com.haitai.solr.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


public class Test {
//    public static void main(String[] args) {
//        Map<String, String> map = new HashMap<>();
//        map.put("fileguid", UUID.randomUUID().toString().replace("-", ""));
//        map.put("dfiletype", "1");
//        map.put("fepguid", UUID.randomUUID().toString().replace("-", ""));
//        map.put("subid", UUID.randomUUID().toString().replace("-", ""));
//        map.put("filepath", "E:/haitai/ermspath/serverDataFile/202105/" + UUID.randomUUID().toString().replace("-", "") + ".txt");
//        map.put("dfilename", "蝶恋花 -感怀5");
//        map.put("mj", "1");
//        map.put("createtime", "2021-06-09 12:00:01");
//        String content = "5年老繁华不愿看，百态人生，样样皆虚幻。说破红尘甘苦伴，沧桑过往无从算。常想真情能否换？予我相思，反予穿心箭。眼底干枯肠早断，谁能比尔还疲倦？";
//        map.put("dfilecontext", content);
//        String out = null;
//        try {
//            out = Base64.getEncoder().encodeToString(JSON.toJSONString(map).getBytes("UTF-8"));
////            System.out.println(new String(Base64.getDecoder().decode(out.getBytes("UTF-8"))));
//            String url = "http://localhost:8085/solr/operation/addInfo";
//            HashMap<String, String> paramMap = new HashMap<String, String>();
//            paramMap.put("coreName", "fileStorage");
//            paramMap.put("reqJson", out);
//            HttpclientTools.ampost(url, paramMap);
//            System.out.println(url +"?" + paramMap.toString());
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("fileguid", UUID.randomUUID().toString().replace("-", ""));
        map.put("dfiletype", "1");
        map.put("fepguid", UUID.randomUUID().toString().replace("-", ""));
        map.put("subid", UUID.randomUUID().toString().replace("-", ""));
        map.put("filepath", "E:/haitai/ermspath/serverDataFile/202105/" + UUID.randomUUID().toString().replace("-", "") + ".txt");
        map.put("dfilename", "蝶恋花 -感怀");
        map.put("mj", "1");
        map.put("createtime", "2021-06-09 12:00:01");
        String content = "年老繁华不愿看，百态人生，样样皆虚幻。说破红尘甘苦伴，沧桑过往无从算。常想真情能否换？予我相思，反予穿心箭。眼底干枯肠早断，谁能比尔还疲倦？";
        map.put("dfilecontext", content);
        String out = null;
        try {
            out = Base64.getEncoder().encodeToString(JSON.toJSONString(map).getBytes("UTF-8"));
//            System.out.println(new String(Base64.getDecoder().decode(out.getBytes("UTF-8"))));
            String url = "http://localhost:8085/solr/operation/addInfo";
            HashMap<String, String> paramMap = new HashMap<String, String>();
            paramMap.put("coreName", "fileStorage");
            paramMap.put("reqJson", out);
            HttpclientTools.ampost(url, paramMap);
            System.out.println(url +"?" + paramMap.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
